<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>여기에 제목을 입력하세요.</title>

<!-- 모바일 웹 페이지 설정 -->
<link rel="shortcut icon" href="assets/ico/favicon.png" />
<link rel="apple-touch-icon-precomposed"
	href="assets/ico/apple-touch-icon-57-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72"
	href="assets/ico/apple-touch-icon-72-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114"
	href="assets/ico/apple-touch-icon-114-precomposed.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144"
	href="assets/ico/apple-touch-icon-144-precomposed.png" />

<!-- bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css" />

<!-- jquery-ui(popup) -->
<link rel="stylesheet"
	href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

<!-- 폰트 적용 -->
<link href='http://fonts.googleapis.com/css?family=Chango'
	rel='stylesheet' type='text/css'>

<!-- font-awesome 적용 -->
<link rel="stylesheet"
	href="assets/font-awesome-4.0.3/css/font-awesome.min.css" />

<!-- custom css 적용 -->
<link rel="stylesheet" href="assets/css/index.css">
<!-- 반응형 웹을 지원하지 않을 경우 -->
<!-- <link rel="stylesheet" href="assets/css/non-responsive.css" /> -->

<!-- IE8 이하 버전 지원 -->
<!--[if lt IE 9]>
		<script type="text/javascript" src="assets/js/html5shiv.js"></script>
		<script type="text/javascript" src="assets/js/respond.min.js"></script>
		<![endif]-->

<!-- IE10 반응형 웹 버그 보완 -->
<!--[if gt IE 9]>
		<link rel="stylesheet" type="text/css" href="assets/css/ie10.css" />
		<script type="text/javascript" src="assets/js/ie10.js"></script>
		<![endif]-->
</head>
<body>

	<!-- Javascript -->
	<script src="assets/js/jquery.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function() {
			var last_response_location = localStorage.length - 1;
			alert(last_response_location);
			var last_response_key = localStorage.key(last_response_location);
			alert(last_response_key);
			var last_response = JSON.parse(localStorage[last_response_key]);
			
			var dis = distance(last_response.end_location.nb,last_response.end_location.ob,last_response.start_location.nb,last_response.start_location.ob);
			if (dis > 50) {
				alert(dis);
			}
		});
	
		function toRadians(degree){
			return degree * Math.PI /180;
		}

		function distance(latitude1,longitude1,latitude2,longitude2){
			//R은 지구 반지름을 킬로미터로 환산한 값
			var R = 6378.1;
			var deltaLatitude = toRadians(latitude2-latitude1);
			var deltaLongitude = toRadians(longitude2-longitude1);
			latitude1 = toRadians(latitude1);
			latitude2 = toRadians(latitude2);

			var a = Math.sin(deltaLatitude/2) * Math.sin(deltaLatitude/2) + Math.cos(latitude1) * Math.cos(latitude2) * Math.sin(deltaLongitude/2) * Math.sin(deltaLongitude/2);
			var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
			var d = R * c;

			return d * 1000;
		}
	</script>
</body>
</html>